#ifndef VAULT_U_H__
#define VAULT_U_H__

#include <stdint.h>
#include <wchar.h>
#include <stddef.h>
#include <string.h>
#include "sgx_edger8r.h" /* for sgx_status_t etc. */


#define SGX_CAST(type, item) ((type)(item))

#ifdef __cplusplus
extern "C" {
#endif

#ifndef SGX_OC_CPUIDEX_DEFINED__
#define SGX_OC_CPUIDEX_DEFINED__
void SGX_UBRIDGE(SGX_CDECL, sgx_oc_cpuidex, (int cpuinfo[4], int leaf, int subleaf));
#endif
#ifndef SGX_THREAD_WAIT_UNTRUSTED_EVENT_OCALL_DEFINED__
#define SGX_THREAD_WAIT_UNTRUSTED_EVENT_OCALL_DEFINED__
int SGX_UBRIDGE(SGX_CDECL, sgx_thread_wait_untrusted_event_ocall, (const void* self));
#endif
#ifndef SGX_THREAD_SET_UNTRUSTED_EVENT_OCALL_DEFINED__
#define SGX_THREAD_SET_UNTRUSTED_EVENT_OCALL_DEFINED__
int SGX_UBRIDGE(SGX_CDECL, sgx_thread_set_untrusted_event_ocall, (const void* waiter));
#endif
#ifndef SGX_THREAD_SETWAIT_UNTRUSTED_EVENTS_OCALL_DEFINED__
#define SGX_THREAD_SETWAIT_UNTRUSTED_EVENTS_OCALL_DEFINED__
int SGX_UBRIDGE(SGX_CDECL, sgx_thread_setwait_untrusted_events_ocall, (const void* waiter, const void* self));
#endif
#ifndef SGX_THREAD_SET_MULTIPLE_UNTRUSTED_EVENTS_OCALL_DEFINED__
#define SGX_THREAD_SET_MULTIPLE_UNTRUSTED_EVENTS_OCALL_DEFINED__
int SGX_UBRIDGE(SGX_CDECL, sgx_thread_set_multiple_untrusted_events_ocall, (const void** waiters, size_t total));
#endif
#ifndef OCALL_GET_STRING_DEFINED__
#define OCALL_GET_STRING_DEFINED__
void SGX_UBRIDGE(SGX_NOCONVENTION, ocall_get_string, (char* buf, int len));
#endif
#ifndef OCALL_PRINT_STRING_DEFINED__
#define OCALL_PRINT_STRING_DEFINED__
void SGX_UBRIDGE(SGX_NOCONVENTION, ocall_print_string, (const char* string));
#endif
#ifndef OCALL_LOG_INFO_DEFINED__
#define OCALL_LOG_INFO_DEFINED__
void SGX_UBRIDGE(SGX_NOCONVENTION, ocall_log_info, (const char* buf));
#endif
#ifndef OCALL_LOG_WARNING_DEFINED__
#define OCALL_LOG_WARNING_DEFINED__
void SGX_UBRIDGE(SGX_NOCONVENTION, ocall_log_warning, (const char* buf));
#endif
#ifndef OCALL_LOG_ERROR_DEFINED__
#define OCALL_LOG_ERROR_DEFINED__
void SGX_UBRIDGE(SGX_NOCONVENTION, ocall_log_error, (const char* buf));
#endif
#ifndef OCALL_LOG_FATAL_DEFINED__
#define OCALL_LOG_FATAL_DEFINED__
void SGX_UBRIDGE(SGX_NOCONVENTION, ocall_log_fatal, (const char* buf));
#endif
#ifndef OCALL_FOPEN_DEFINED__
#define OCALL_FOPEN_DEFINED__
int SGX_UBRIDGE(SGX_NOCONVENTION, ocall_fopen, (_int64* file, const char* file_name, const char* mode));
#endif
#ifndef OCALL_FCLOSE_DEFINED__
#define OCALL_FCLOSE_DEFINED__
int SGX_UBRIDGE(SGX_NOCONVENTION, ocall_fclose, (_int64 file));
#endif
#ifndef OCALL_FPUTS_DEFINED__
#define OCALL_FPUTS_DEFINED__
int SGX_UBRIDGE(SGX_NOCONVENTION, ocall_fputs, (_int64 file, const char* buf));
#endif
#ifndef OCALL_FSEEK_DEFINED__
#define OCALL_FSEEK_DEFINED__
int SGX_UBRIDGE(SGX_NOCONVENTION, ocall_fseek, (_int64 file, long int offset, int origin));
#endif
#ifndef OCALL_FTELL_DEFINED__
#define OCALL_FTELL_DEFINED__
long int SGX_UBRIDGE(SGX_NOCONVENTION, ocall_ftell, (_int64 file));
#endif
#ifndef OCALL_FREAD_DEFINED__
#define OCALL_FREAD_DEFINED__
size_t SGX_UBRIDGE(SGX_NOCONVENTION, ocall_fread, (_int64 file, void* buf, int buf_len, size_t element_size, size_t element_count));
#endif
#ifndef OCALL_FGETS_DEFINED__
#define OCALL_FGETS_DEFINED__
char* SGX_UBRIDGE(SGX_NOCONVENTION, ocall_fgets, (_int64 file, char* buf, int buf_len));
#endif
#ifndef OCALL_IS_DIR_EXSIT_DEFINED__
#define OCALL_IS_DIR_EXSIT_DEFINED__
int SGX_UBRIDGE(SGX_NOCONVENTION, ocall_is_dir_exsit, (const char* dri_name));
#endif
#ifndef OCALL_MAKE_DIR_DEFINED__
#define OCALL_MAKE_DIR_DEFINED__
int SGX_UBRIDGE(SGX_NOCONVENTION, ocall_make_dir, (const char* dir_name));
#endif
#ifndef U_SGXSSL_FTIME64_DEFINED__
#define U_SGXSSL_FTIME64_DEFINED__
void SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxssl_ftime64, (void* timeptr, uint32_t timeb64Len));
#endif

sgx_status_t initVault(sgx_enclave_id_t eid, int* retval, const char* id);
sgx_status_t uninitVault(sgx_enclave_id_t eid, int* retval, const char* id);
sgx_status_t encrypt(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t encrypt_size(sgx_enclave_id_t eid, int* retval, const char* id, int buf_len);
sgx_status_t encryptex(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, const int* value_lens, const int* value_types, int value_count, char* out_buf, int out_buf_size, int* out_value_lens);
sgx_status_t decrypt(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t public_key_encrypt(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t private_key_decrypt(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t private_key_encrypt(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t public_key_decrypt(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t sign(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t sha256_encrytp(sgx_enclave_id_t eid, int* retval, const char* id, const char* in_buf, int in_buf_len, char* out_buf, int out_buf_size);
sgx_status_t crypto_key(sgx_enclave_id_t eid, int* retval, const char* id, char* key, int key_len);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif
